<%@ page contentType="text/html" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
 
<s:layout-render name="/menu.jsp" title="players">
    <s:layout-component name="body">
        <s:useActionBean beanclass="com.mycompany.sportclubmanager.PlayersActionBean" var="actionBean"/>

		<h1><fmt:message key="players_list" /></h1>

		<div class="list-options">
			<s:link href="/players/edit" class="button">
				<span class="icon icon-plus"></span>
				<fmt:message key="add_new_player" />
			</s:link>
		</div>

		<table class="table" cellpadding="0" cellspacing="0">
            <tr>
                <th><fmt:message key="id" /></th>
                <th><fmt:message key="firstname" /></th>
                <th><fmt:message key="lastname" /></th>
                <th><fmt:message key="birthdate" /></th>
                <th><fmt:message key="height" /></th>
                <th><fmt:message key="weight" /></th>
                <th></th>
            </tr>
            <c:forEach items="${actionBean.players}" var="player">
                <tr>
                    <td class="table-item-id">${player.id}</td>
                    <td><c:out value="${player.firstName}"/></td>
                    <td><c:out value="${player.lastName}"/></td>
                    <td><c:out value="${player.birthDate}"/></td>
                    <td><c:out value="${player.height}"/></td>
                    <td><c:out value="${player.weight}"/></td>
                    <td class="table-item-options">
						<s:link beanclass="com.mycompany.sportclubmanager.PlayersActionBean" event="delete" rel="delete-player">
							<s:param name="player.id" value="${player.id}"/>
							<span class="icon icon-delete" title="DELETE"></span>
						</s:link>
						<s:link beanclass="com.mycompany.sportclubmanager.PlayersActionBean" event="edit">
							<s:param name="player.id" value="${player.id}"/>
							<span class="icon icon-edit" title="EDIT"></span>
						</s:link>
					</td>
                </tr>
            </c:forEach>
        </table>

		<script>
			$(function() {
				$('[rel="delete-player"]').click(function() {
					return confirm("TODO: remove message");
				})
			})
		</script>

    </s:layout-component>
</s:layout-render>